package com.ssm.service.imp;

import com.github.pagehelper.PageHelper;
import com.ssm.mapper.CustomerMapper;
import com.ssm.mapper.ProductMapper;
import com.ssm.mapper.QuotationMapper;
import com.ssm.pojo.Customer;
import com.ssm.pojo.Product;
import com.ssm.pojo.Quotation;
import com.ssm.service.QuotationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("quotationServiceImp")
public class QuotationServiceImp implements QuotationService {

    @Autowired
    private QuotationMapper quotationMapper;

    @Autowired
    private ProductMapper productMapper;

    @Autowired
    private CustomerMapper customerMapper;

    public void insertQuo(Quotation quotation) {
        quotationMapper.insertQ(quotation);
    }

    public void deleteQuo(String quoNO) {
        quotationMapper.deleteQ(quoNO);
    }

    public void updateQuo(Quotation quotation) {
        quotationMapper.updateQ(quotation);
    }

    public List<Quotation> selectQuo() {
        return quotationMapper.selectQ();
    }

    //分页查询报价信息所有报价信息
    public List<Quotation> selectQuoPage(String quoNO, Integer pageNum, Integer pageSize){
        if(pageNum!=null && pageSize!=null){
            PageHelper.startPage(pageNum, pageSize);
        }
        List<Quotation> quotations = quotationMapper.selectQuoPage(quoNO);

        return quotations;
    }

    public Integer selectQuoSize(String quoNO) {
        return quotationMapper.selectQuoSize(quoNO);
    }

    public Quotation selectByQuotationNO(String quoId) {
        Quotation q = quotationMapper.selectByQuotationNO(quoId);
        return q;
    }
}
